﻿myApp.controller("auctionDetailController", function ($scope, $http, $modal, modalService, $routeParams, $location) {

    // Address, Type, Price, Land/BuildUp Area, AuctionDate, Sale AgentName, Contact, Photo
    $scope.share = {};
   function pageInit() {
       var url = 'api/Auction/GetAuction/' + $routeParams.id;
       $http.get(url).success(function (data) {
           console.log(data.Auction);
           $scope.Auction = data.Auction;
           $scope.Auction.StartDateTime = new Date($scope.Auction.StartDateTime);
           $scope.Auction.EndDateTime = new Date($scope.Auction.EndDateTime);
           $scope.slides = data.pictureList;
           //$scope.slides.push({ pictureURL: $scope.Auction.StaffPicURL });
           if (!$scope.slides) {
               $scope.slides = [];
               $scope.slides.push({ pictureURL: 'http://www.penangrealty.my/images/penang realty,Apartment,house,condominium,terrace house,semi d,detached,bungalow,high end luxury properties,landed properties,gated guarded house.png' });
           }

           $scope.share.url = 'http://www.penangrealty.my/AuctionDetail/' + $routeParams.id.toString();
            $scope.share.pictureUrl = $scope.slides ? $scope.slides[0].pictureURL : 'http://www.penangrealty.my/images/penang realty,Apartment,house,condominium,terrace house,semi d,detached,bungalow,high end luxury properties,landed properties,gated guarded house.png';
            $scope.share.title = '[拍卖 AUCTION] ' + $scope.Auction.Address
            $scope.share.description = "Price : " + $scope.Auction.Price.toLocaleString()
+ ', Land Area : ' + $scope.Auction.LandArea
+ ', Date : ' + $scope.Auction.AuctionDate
//+ " Contact: " + $scope.property.mobile + " (" + $scope.property.agentname + ")";
            document.title = "Penang Realty AUCTION 世界地產" + $scope.share.title;
            $scope.$emit('newPageLoaded', { 'title': $scope.share.title, 'description': $scope.share.description });
        })

    }
    pageInit();
   //console.log("AuctionDetail controller loaded");
});